import request from '@/service/index.js'

export const queryOrderList = (params) => {
  return request.get('/order/list', { params: params })
}

export const editOrderNote = (id, note) => {
  return request.patch(`/order/merchantNote`, {
    orderId: id,
    merchantNote: note,
  })
}

export const updateOrderActualPrice = (id, price) => {
  return request.patch('/order/editOrderPrice', {
    orderId: id,
    actualPayment: price,
  })
}

export const closeOrder = (id) => {
  return request.patch(`/order/close/${id}`)
}

export const queryOrderDetail = (orderId) => {
  return request.get('/order/detail', { params: { orderId } })
}

export const confirmThePayment = (orderId) => {
  return request.patch('/order/confirm/payment', null, {
    params: {
      orderId: orderId, // 这里的参数会被 Axios 自动拼接到 URL 后（?orderId=xxx）
    },
  })
}

export const confirmTheShipment = (orderId, deliveryType, trackingNumber) => {
  return request.patch('/order/confirm/shipment', {
    orderId: orderId,
    deliveryType: deliveryType,
    trackingNumber: trackingNumber,
  })
}

export const confirmTheReceipt = (orderId) => {
  return request.patch(`/order/confirm/receipt`, null, {
    params: {
      orderId: orderId,
    },
  })
}

export const queryExpressInfo = (orderId) => {
  return request.get('/order/delivery/information', { params: { orderId } })
}

export const updateExpressInfo = (orderId, deliveryType, trackingNumber) => {
  return request.patch('/order/update/delivery/information', {
    orderId: orderId,
    deliveryType: deliveryType,
    trackingNumber: trackingNumber,
  })
}
